package com.demo.controller;

import com.demo.domain.entity.User;
import com.demo.domain.vo.UserLoginVo;
import com.demo.service.UserService;
import com.demo.utils.base.WebResponse;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Copyright
 *
 * @Author WuHuang
 * @Date 2025/6/20
 */
@RestController
@RequestMapping("/login")
@Tag(name = "登录管理")
public class LoginController {

    @Autowired
    private UserService userService;

    /**
     * 查询User列表
     */
    @PostMapping("/register")
    @Operation(summary = "注册")
    public WebResponse<Boolean> register(@RequestBody UserLoginVo userLoginVo){

        return WebResponse.success(userService.register(userLoginVo));
    }

    /**
     * 查询User列表
     */
    @GetMapping("/get/code")
    @Operation(summary = "获取验证码")
    public WebResponse<String> getCode(){
        return WebResponse.success(userService.getCode());
    }

    /**
     * 查询User列表
     */
    @GetMapping("/code")
    @Operation(summary = "校验验证码")
    public WebResponse<Boolean> getCode(String code){
        return WebResponse.success(userService.code(code));
    }
}
